import request from "@/utils/request";
import type { LoginForm, LoginResponseData, UserInfoResponseData } from "./types";

// 统一管理接口
const API = {
  LOGIN_URL: "/admin/acl/index/login",
  USERINFO_URL: "/admin/acl/index/info",
  LOGOUT_URL: "/admin/acl/index/logout",
};

// 登录
export function reqLogin(data: LoginForm): Promise<LoginResponseData> {
  return request({
    url: API.LOGIN_URL,
    method: "post",
    data,
  });
}

// 获取用户信息
export function reqUserInfo(): Promise<UserInfoResponseData> {
  return request({
    url: API.USERINFO_URL,
    method: "get",
  });
}

// 退出登录
export function reqLogout(): Promise<any> {
  return request({
    url: API.LOGOUT_URL,
    method: "post",
  });
}